package com.ss.android.article.base.ui;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;

import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.UIUtils;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Orientation;
import com.handmark.pulltorefresh.library.internal.LoadingLayout;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.browser.R;

public class SSLoadingLayout extends LoadingLayout {
    private PullLoadingView m;
    private float n;

    public SSLoadingLayout(Context arg6, Mode arg7, Orientation arg8, TypedArray arg9) {
        super(arg6, arg7, arg8, arg9);
        float v4 = 26f;
        float v3 = 16f;
        this.n = -1f;
        if((this.c instanceof PullLoadingView)) {
            this.m = (PullLoadingView) this.c;
        }

        UIUtils.setBackgroundColor(((View)this), this.getResources(), R.color.ssxinmian3);
        if(this.m != null) {
            int v1 = ((int) UIUtils.dp2px(this.getContext(), 14f));
            if((this.m.getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) {
                ViewGroup.LayoutParams v0 = this.m.getLayoutParams();
                if(!AppData.getInstance().getAbSettings().isSSLoadingViewNewStyle()) {
                    ((ViewGroup.MarginLayoutParams)v0).height = ((int) UIUtils.dp2px(this.getContext(), v4));
                    ((ViewGroup.MarginLayoutParams)v0).width = ((int) UIUtils.dp2px(this.getContext(), v4));
                    ((ViewGroup.MarginLayoutParams)v0).bottomMargin = ((int) UIUtils.dp2px(this.getContext(), 6f));
                }
                else {
                    v1 = ((int) UIUtils.dp2px(this.getContext(), 12f));
                    ((ViewGroup.MarginLayoutParams)v0).height = ((int) UIUtils.dp2px(this.getContext(), v3));
                    ((ViewGroup.MarginLayoutParams)v0).width = ((int) UIUtils.dp2px(this.getContext(), v3));
                    ((ViewGroup.MarginLayoutParams)v0).bottomMargin = ((int) UIUtils.dp2px(this.getContext(), 4f));
                }

                ((ViewGroup.MarginLayoutParams)v0).topMargin = v1;
                this.m.setLayoutParams(v0);
            }
            else {
                Logger.e("SSLoadingLayout", "PullLoadingView's LayoutParams is not MarginLayoutParams.");
            }

            this.n = (((float)v1)) * 1.2f;
        }
    }

    public final int a(Orientation arg2) {
        return R.layout.pull_to_refresh_header_ss;
    }

    public final void a() {
    }

    public final void a(float arg5) {
        if(this.m != null && this.n > 0f) {
            int v0 = this.getContentSize();
            this.m.setPullProgress(Math.max((((float)v0)) * arg5 - ((((float)v0)) - this.n), 0f) / this.n);
        }
    }

    public final void a(Drawable arg1) {
    }

    public final void b() {
        if(this.m != null) {
            this.m.startAnimation(null);
        }
    }

    public final void c() {
    }

    public final void d() {
        if(this.m != null) {
            this.m.clearAnimation();
        }
    }

    public int getDefaultDrawableResId() {
        return R.drawable.o1;
    }

    public void setLoadingDrawable(Drawable loadingDrawable) {
    }

    public void setTheme(boolean isNightMode) {
        super.setTheme(isNightMode);
        if(this.m != null) {
            this.m.setTheme(isNightMode);
        }

        UIUtils.setBackgroundColor(((View)this), this.getResources(), R.color.ssxinmian3);
    }
}

